package Lesson16;

class Person 
{

	public String name;
	private int age;
	private String password; //set in constructor//make method changePassword(String oldPass, String newPass)
	String address;
	private final String egn;
	static String courseName = "JAVAEE";
	
	City c = new City();
	
	public Person(String egn, String password)
	{
		name = "Ivan";
		age = 0;
		this.egn = egn;
		this.password = password;
	}
	
	void changeCity(final City newCity)
	{
		c = newCity;
	}
	public void changePassword(String password, String newPassword, String confirmNewPassword)
	{
		if(newPassword.equals(confirmNewPassword))
		{
			if(this.password.equals(password))
			{
				this.password = newPassword;
			}
			else
			{
				System.out.println("Old password mismatch!");
			}
		}
		else
		{
			System.out.println("New password missmatch!");
		}
	}
	
	void setAge(int newAge)
	{
		if(newAge >=0 && newAge < 150)
		this.age = newAge;
	}
	
	int getAge(String password)
	{
		if(this.password.equals(password))
			return age;
		else
			return -1;
	}
	static int getPensionAge()
	{
		return 65;
	}
	static int calcWorkingYearsLeft(int currentAge)
	{
		return getPensionAge()-currentAge;
	}
}
